<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <h:body>
        <ui:composition template="./communityTemplate.xhtml">
            <ui:define name="content">

                <h:form>  
                    <p:dataTable var="message" value="#{chatBean.messages}" 
                                 id="table1" 
                                 rows="20" rendered="true" paginator="TRUE" 
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
                                 rowsPerPageTemplate="20,50,100,200">  
                        <p:column >  
                            <f:facet name="header">  
                                Time sent  
                            </f:facet>  
                            <h:outputText value="#{message.modifiedDateString}" /> 
                        </p:column>  

                        <p:column>  
                            <f:facet name="header">  
                                Sender  
                            </f:facet>  
                            <h:outputText value="#{message.sender.name}" />  
                        </p:column>  

                        <p:column>  
                            <f:facet name="header">  
                                Message  
                            </f:facet>  
                            <h:outputText value="#{message.message}" />  
                        </p:column>  
 
                    </p:dataTable>  
                    <p:poll interval="3" update="table1" widgetVar="poll" autoStart="true"/> 
                </h:form>  

                <h:form id="submitForm">
                    <p:inputTextarea value="#{chatBean.message}" cols="43" rows="5" autoResize="FALSE"/>
                    <p:commandButton value="Submit" action="#{chatBean.postMessage()}" ajax="true" update="submitForm"/>
                </h:form>




            </ui:define>
        </ui:composition>
    </h:body>

</html>

